package com.april.pattern.behavioral.visitor;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @author April
 * @version V1.0.0
 * @date 2019/07/09 17:15
 * @description 访问者模式
 */
public class VisitorTest {
    @Test
    public void visitorTest() {
        List<Course> courseList = new ArrayList<>();

        FreeCourse freeCourse = new FreeCourse();
        freeCourse.setName("SpringMVC数据绑定");

        CodingCourse codingCourse = new CodingCourse();
        codingCourse.setName("Java设计模式精讲");
        codingCourse.setPrice(299);

        courseList.add(freeCourse);
        courseList.add(codingCourse);

        for (Course course : courseList) {
            course.accept(new VisitorImpl());
        }
    }
}
